﻿Option Strict Off
Option Explicit On

Namespace Base
    Public MustInherit Class Lista
        Protected m_List As ArrayList
        Protected m_Keys As Object
        Protected m_Index As Short
        Protected m_EOF As Boolean

        Protected m_Item As Object

        Public ReadOnly Property Items() As ArrayList
            Get
                Return m_List
            End Get
        End Property

        Public ReadOnly Property Count() As Short
            Get
                Return m_List.Count
            End Get
        End Property

        Public Sub Remove(ByVal Key As String)
            Remove(Key, True)
        End Sub

        Public Overridable Sub Remove(ByVal Key As String, ByVal Refresh As Boolean)
            If m_List.Contains(Key) Then
                m_List.Remove(Key)
                If Refresh Then
                    toRefresh()
                End If
            End If
        End Sub

        Public Overridable Sub RemoveAll()
            RemoveAll(True)
        End Sub

        Public Overridable Sub RemoveAll(ByVal Refresh As Boolean)
            m_List.Clear()

            If Refresh Then
                toRefresh()
            End If
        End Sub

        Public Overridable Function Exists(ByVal Key As String) As Boolean
            Return m_List.Contains(Key)
        End Function

        Public Sub toRefresh()
            'If Not m_List Is Nothing Then
            '    If IsArray(m_Keys) > 0 Then
            '        Erase m_Keys

            '        m_Keys = Nothing
            '    End If

            '    m_Keys = m_List.Keys
            '    m_Index = -1
            '    m_Item = Nothing

            '    If m_List.Count > 0 Then
            '        m_EOF = False
            '    Else
            '        m_EOF = True
            '    End If
            'End If
        End Sub

        'Private Function SortedHashTable() As ICollection
        '    Return SortedHashTable(m_List)
        'End Function

        'Private Function SortedHashTable(ByVal ht As Hashtable) As ICollection
        '    Dim sorter As ArrayList = New ArrayList()
        '    sorter.AddRange(ht)
        '    sorter.Sort()

        '    Return sorter
        'End Function

        Public Sub New()
            MyBase.New()

            m_List = New ArrayList
            m_EOF = True
        End Sub

        Protected Overrides Sub Finalize()
            m_List = Nothing
            m_Item = Nothing

            MyBase.Finalize()
        End Sub
    End Class
End Namespace